#ifndef MAPLAYER_H
#define MAPLAYER_H

#include <QString>
#include <QJsonObject>
#include <QMetaType>

class MapLayer
{
public:
    enum LayerType {
        GridLayer,
        MBTilesLayer,
        AmapLayer,
        TianDiTuLayer,
        OtherLayer
    };

    MapLayer();
    MapLayer(const QString &name, LayerType type, const QString &source, bool visible = true);

    QString name() const;    
    void setName(const QString &name);
    
    LayerType type() const;
    void setType(LayerType type);
    
    QString source() const;
    void setSource(const QString &source);
    
    bool isVisible() const;
    void setVisible(bool visible);
    
    // 将图层信息转换为JSON对象
    QJsonObject toJson() const;
    
    // 从JSON对象创建图层
    static MapLayer fromJson(const QJsonObject &json);
    
    // 获取图层类型的字符串表示
    QString typeToString() const;
    
    // 从字符串转换为图层类型
    static LayerType stringToType(const QString &typeStr);

private:
    QString m_name;
    LayerType m_type;
    QString m_source;
    bool m_visible;
};

Q_DECLARE_METATYPE(MapLayer)

#endif // MAPLAYER_H